<template>
  <div>
    <nav-bar :title="$t('myModel.myCode.myCode')"></nav-bar>
    <div class="personal maxinBox center">
      <div class="userInfo" v-if="userInfo">
        <van-row>
          <van-col :span="7">
            <img :src="userInfo.headUrl" alt="" class="avatar">
          </van-col>
          <van-col :span="17" class="nickname">{{userInfo.name}}</van-col>
        </van-row>
        <img :src="userCodeUrl" alt="" class="qrCode">
        <van-button round block plain type="info" @click="$router.go(-1)">
          {{$t('myModel.myCode.close')}}
        </van-button>
      </div>
    </div>
  </div>
</template>

<script>
  import myAPI from '../../../api/myAPI.js'
  export default {
    data() {
      return {
        userCodeUrl: localStorage.getItem('userCode'),
        userInfo: null
      }
    },
    methods:{
      // 查询用户信息
      getUserInfo() {
        myAPI.getUserInfo().then(res => {
          this.userInfo = res
        })
      }
    },
    mounted() {
      this.getUserInfo()
    }
  }
</script>
<style scoped lang="scss">
  .personal{
    padding: 3.125rem 1.1875rem;
  }
</style>
